package com.graduation.mobile.controller;

import java.util.List;
import java.util.Map;

import org.hibernate.Query;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import cn.circle.commom.dao.impl.BaseDaoImpl;
import com.graduation.system.model.SysDepartment;
import com.graduation.system.model.SysLostAndFound;
import cn.circle.system.util.ReturnInfo;

@Controller
@EnableWebMvc
public class LostAndFoundController extends BaseDaoImpl<SysLostAndFound>{

	@SuppressWarnings("unchecked")
	@ResponseBody
	@RequestMapping(value = "/mobile/getLostAndFound")
	public ReturnInfo index(ReturnInfo r,Integer page,Integer rows) {
		if(page !=null && rows !=null){
			List<SysLostAndFound> lstAll = null;
			try{
				String hql ="from SysLostAndFound l where l.status = 9 order by releaseTime desc";
				lstAll = super.find(hql, page, rows);
				r.setRows(super.count("select count(*) " + hql)); // 总记录数
				r.setObj(lstAll);
			}catch (Exception e) {
				System.out.println("异常" + e.getMessage());
				}
			}
		return r;
	}
	/**
	 * 获得失物招领详细资料
	 */
	@RequestMapping(value = "/mobile/goLAFDetail")
	public String goLAFDetail(String id, Map<String, Object> map) {
		if (id != null) {
			String hql = "from SysLostAndFound s where s.arcitleId = "+id+" ";
			Query query = super.sessionFactory.getCurrentSession().createQuery(hql);
			List<SysLostAndFound> model = query.list();
			map.put("model", model.get(0));
		}
		return "/WEB-INF/jsp/mobile/main/schoolLive/LostAndFound/LAFDetail.jsp";
	}
	

}
